﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            DataTable studt = new DataTable("student");
            DataColumn sno=new DataColumn();
            sno=studt.Columns.Add("sno",typeof(int));
            sno.AllowDBNull = false;
            sno.Unique = true;
            DataColumn sname = new DataColumn();
            sname = studt.Columns.Add("sname", typeof(string));
            sname.AllowDBNull = false;
            sname.Unique = false;
            DataColumn ssex = new DataColumn();
            ssex = studt.Columns.Add("ssex", typeof(string));
            ssex.AllowDBNull = false;
            ssex.Unique = false;
            ssex.DefaultValue = "男";
            DataColumn sbirthday = new DataColumn();
            sbirthday = studt.Columns.Add("sbirthday", typeof(string));
            sbirthday.DefaultValue = DateTime.Now.ToLongDateString();
            studt.Columns.Add("class", typeof(string));
            DataRow dr = studt.NewRow();
            dr["sno"] = 1001;
            dr["sname"] = "张三";
            dr["ssex"] = "男";
            dr["sbirthday"] = "1980-2-1";
            dr["class"] = "98002";
            studt.Rows.Add(dr);
            for (int i = 0; i < studt.Rows.Count; i++)
            {
                label1.Text = "编号:" + dr["sno"].ToString() + ";姓名:" + dr["sno"].ToString() +
                ";性别:" + dr["ssex"].ToString() + ";生日:" + dr["sbirthday"].ToString() +
                ";班级:" + dr["class"].ToString();
            }

        }
    }
}
